#ifndef __COMMUNICATION_H
#define __COMMUNICATION_H

#define TYPE_REQUEST 0x1
#define TYPE_ACK 0x2
#define TYPE_ACK_ACK 0x3
#define TYPE_REQUEST_DATA 0x4
#define TYPE_ACK_DATA 0x5


#define CONTENT_AUDIO_OUT 0x1
#define CONTENT_AUDIO_IN 0x2
#define CONTENT_RS485_TEST 0x3
#define CONTENT_AUDIO_PAR 0x4
#define CONTENT_TIME_SYN 0x5
#define CONTENT_NOISE_CAL 0x6
#define CONTENT_NOISE_PLAY 0x7
#define CONTENT_ENTER_NORMAL 0x8

#define ERR_CODE_OK 0x0
#define ERR_CODE_BUSY 0x1
#define ERR_CODE_TIME 0x2
#define ERR_CODE_FILE 0x3
#define ERR_CODE_ANALYSIS 0x4


typedef struct
{
	unsigned char type;
	unsigned char sn;
	unsigned char content;
	unsigned char data_len;
	char data[0];
}S_PACKET_DATA, *PS_PACKET_DATA;

typedef struct
{
	char err_no;
	char reserve[3];
	char err_data[0];
}S_PACKET_ERR_DATA, *PS_PACKET_ERR_DATA;

int init_communication_protocol();
int send_ack_packet(char err_no, PS_PACKET_DATA pstRequest, struct sockaddr *pstAddr);
int send_ack_data_packet(char err_no, PS_PACKET_DATA pstRequest, struct sockaddr *pstAddr, char *data, int data_len);
void *communication(void *arg);




#endif
